<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: drogon::HttpMiddlewareBase类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacedrogon.html">drogon</a></li><li class="navelem"><a class="el" href="classdrogon_1_1HttpMiddlewareBase.html">HttpMiddlewareBase</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="classdrogon_1_1HttpMiddlewareBase-members.html">所有成员列表</a>  </div>
  <div class="headertitle"><div class="title">drogon::HttpMiddlewareBase类 参考<span class="mlabels"><span class="mlabel">abstract</span></span></div></div>
</div><!--header-->
<div class="contents">

<p>The abstract base class for middleware  
 <a href="classdrogon_1_1HttpMiddlewareBase.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="HttpMiddleware_8h_source.html">HttpMiddleware.h</a>&gt;</code></p>
<div class="dynheader">
类 drogon::HttpMiddlewareBase 继承关系图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1HttpMiddlewareBase__inherit__graph.png" border="0" usemap="#adrogon_1_1HttpMiddlewareBase_inherit__map" alt="Inheritance graph"/></div>
<map name="adrogon_1_1HttpMiddlewareBase_inherit__map" id="adrogon_1_1HttpMiddlewareBase_inherit__map">
<area shape="rect" title="The abstract base class for middleware" alt="" coords="217,106,428,131"/>
<area shape="rect" href="classdrogon_1_1HttpFilterBase.html" title="The abstract base class for filters For more details on the class, see the wiki site (the &#39;Filter&#39; se..." alt="" coords="481,77,649,102"/>
<area shape="poly" title=" " alt="" coords="441,102,481,97,482,102,442,107"/>
<area shape="rect" href="classdrogon_1_1HttpMiddleware.html" title="The reflection base class template for middlewares" alt="" coords="476,127,655,167"/>
<area shape="poly" title=" " alt="" coords="442,130,476,134,475,139,441,135"/>
<area shape="rect" href="classdrogon_1_1DrObjectBase.html" title="The base class for all drogon reflection classes." alt="" coords="5,106,169,131"/>
<area shape="poly" title=" " alt="" coords="183,116,217,116,217,121,183,121"/>
<area shape="rect" href="classdrogon_1_1HttpFilter.html" title=" " alt="" coords="705,5,853,45"/>
<area shape="poly" title=" " alt="" coords="621,70,711,43,712,48,623,75"/>
<area shape="rect" href="classdrogon_1_1HttpFilter.html" title=" " alt="" coords="705,69,854,109"/>
<area shape="poly" title=" " alt="" coords="663,87,705,87,705,92,663,92"/>
<area shape="rect" href="classdrogon_1_1HttpFilter.html" title="The reflection base class template for filters" alt="" coords="703,133,856,173"/>
<area shape="poly" title=" " alt="" coords="625,103,655,112,715,131,714,136,654,117,624,108"/>
<area shape="rect" href="classdrogon_1_1IntranetIpFilter.html" title="A filter that prohibit access from external networks" alt="" coords="905,13,1075,38"/>
<area shape="poly" title=" " alt="" coords="867,23,905,23,905,28,867,28"/>
<area shape="rect" href="classdrogon_1_1LocalHostFilter.html" title="A filter that prohibit access from other hosts." alt="" coords="904,77,1076,102"/>
<area shape="poly" title=" " alt="" coords="868,87,904,87,904,92,868,92"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<div class="dynheader">
drogon::HttpMiddlewareBase 的协作图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1HttpMiddlewareBase__coll__graph.png" border="0" usemap="#adrogon_1_1HttpMiddlewareBase_coll__map" alt="Collaboration graph"/></div>
<map name="adrogon_1_1HttpMiddlewareBase_coll__map" id="adrogon_1_1HttpMiddlewareBase_coll__map">
<area shape="rect" title="The abstract base class for middleware" alt="" coords="5,79,216,104"/>
<area shape="rect" href="classdrogon_1_1DrObjectBase.html" title="The base class for all drogon reflection classes." alt="" coords="29,5,193,31"/>
<area shape="poly" title=" " alt="" coords="113,44,113,79,108,79,108,44"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:aa024a7530a819e97d179c0ea7aa82cbc" id="r_aa024a7530a819e97d179c0ea7aa82cbc"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1HttpMiddlewareBase.html#aa024a7530a819e97d179c0ea7aa82cbc">invoke</a> (const <a class="el" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> &amp;req, <a class="el" href="namespacedrogon.html#aac356e8eb8bbc103efe2910214850e98">MiddlewareNextCallback</a> &amp;&amp;nextCb, <a class="el" href="namespacedrogon.html#a6a361b482e0084d11cbebeed1677d577">MiddlewareCallback</a> &amp;&amp;mcb)=0</td></tr>
<tr class="separator:aa024a7530a819e97d179c0ea7aa82cbc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af18c5aaadfbad541c4a049cbb6dfb612" id="r_af18c5aaadfbad541c4a049cbb6dfb612"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1HttpMiddlewareBase.html#af18c5aaadfbad541c4a049cbb6dfb612">~HttpMiddlewareBase</a> () override=default</td></tr>
<tr class="separator:af18c5aaadfbad541c4a049cbb6dfb612"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classdrogon_1_1DrObjectBase"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classdrogon_1_1DrObjectBase')"><img src="closed.png" alt="-"/>&#160;Public 成员函数 继承自 <a class="el" href="classdrogon_1_1DrObjectBase.html">drogon::DrObjectBase</a></td></tr>
<tr class="memitem:a3b6f9f93fce1cb61c43bebea00b77582 inherit pub_methods_classdrogon_1_1DrObjectBase" id="r_a3b6f9f93fce1cb61c43bebea00b77582"><td class="memItemLeft" align="right" valign="top">virtual const std::string &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1DrObjectBase.html#a3b6f9f93fce1cb61c43bebea00b77582">className</a> () const</td></tr>
<tr class="memdesc:a3b6f9f93fce1cb61c43bebea00b77582 inherit pub_methods_classdrogon_1_1DrObjectBase"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the class name  <br /></td></tr>
<tr class="separator:a3b6f9f93fce1cb61c43bebea00b77582 inherit pub_methods_classdrogon_1_1DrObjectBase"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a847a57ab1e5cac6e70a910ae5e3f759b inherit pub_methods_classdrogon_1_1DrObjectBase" id="r_a847a57ab1e5cac6e70a910ae5e3f759b"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1DrObjectBase.html#a847a57ab1e5cac6e70a910ae5e3f759b">isClass</a> (const std::string &amp;class_name) const</td></tr>
<tr class="memdesc:a847a57ab1e5cac6e70a910ae5e3f759b inherit pub_methods_classdrogon_1_1DrObjectBase"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return true if the class name is 'class_name'  <br /></td></tr>
<tr class="separator:a847a57ab1e5cac6e70a910ae5e3f759b inherit pub_methods_classdrogon_1_1DrObjectBase"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3a57e74527aea2d71d9f471b39c70d1b inherit pub_methods_classdrogon_1_1DrObjectBase" id="r_a3a57e74527aea2d71d9f471b39c70d1b"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1DrObjectBase.html#a3a57e74527aea2d71d9f471b39c70d1b">~DrObjectBase</a> ()</td></tr>
<tr class="separator:a3a57e74527aea2d71d9f471b39c70d1b inherit pub_methods_classdrogon_1_1DrObjectBase"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>The abstract base class for middleware </p>
</div><h2 class="groupheader">构造及析构函数说明</h2>
<a id="af18c5aaadfbad541c4a049cbb6dfb612" name="af18c5aaadfbad541c4a049cbb6dfb612"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af18c5aaadfbad541c4a049cbb6dfb612">&#9670;&#160;</a></span>~HttpMiddlewareBase()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">drogon::HttpMiddlewareBase::~HttpMiddlewareBase </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">default</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">成员函数说明</h2>
<a id="aa024a7530a819e97d179c0ea7aa82cbc" name="aa024a7530a819e97d179c0ea7aa82cbc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa024a7530a819e97d179c0ea7aa82cbc">&#9670;&#160;</a></span>invoke()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::HttpMiddlewareBase::invoke </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> &amp;&#160;</td>
          <td class="paramname"><em>req</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacedrogon.html#aac356e8eb8bbc103efe2910214850e98">MiddlewareNextCallback</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>nextCb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacedrogon.html#a6a361b482e0084d11cbebeed1677d577">MiddlewareCallback</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>mcb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This virtual function should be overridden in subclasses.</p>
<p>Example: </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1HttpMiddlewareBase.html#aa024a7530a819e97d179c0ea7aa82cbc">invoke</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> &amp;req,</div>
<div class="line">            <a class="code hl_typedef" href="namespacedrogon.html#aac356e8eb8bbc103efe2910214850e98">MiddlewareNextCallback</a> &amp;&amp;nextCb,</div>
<div class="line">            <a class="code hl_typedef" href="namespacedrogon.html#a6a361b482e0084d11cbebeed1677d577">MiddlewareCallback</a> &amp;&amp;mcb)<span class="keyword"> override</span></div>
<div class="line"><span class="keyword"> </span>{</div>
<div class="line">    <span class="keywordflow">if</span> (req-&gt;path() == <span class="stringliteral">&quot;/some/path&quot;</span>) {</div>
<div class="line">        <span class="comment">// intercept directly</span></div>
<div class="line">        mcb(<a class="code hl_function" href="classdrogon_1_1HttpResponse.html#ae7dbe82af88eae091b7684edb67d5f99">HttpResponse::newNotFoundResponse</a>(req));</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">// Do something before calling the next middleware</span></div>
<div class="line">    nextCb([mcb = std::move(mcb)](<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ab2a2d829bb017f43c2c9de72f4042baa">HttpResponsePtr</a> &amp;resp) {</div>
<div class="line">        <span class="comment">// Do something after the next middleware returns</span></div>
<div class="line">        mcb(resp);</div>
<div class="line">    });</div>
<div class="line">}</div>
<div class="ttc" id="aclassdrogon_1_1HttpMiddlewareBase_html_aa024a7530a819e97d179c0ea7aa82cbc"><div class="ttname"><a href="classdrogon_1_1HttpMiddlewareBase.html#aa024a7530a819e97d179c0ea7aa82cbc">drogon::HttpMiddlewareBase::invoke</a></div><div class="ttdeci">virtual void invoke(const HttpRequestPtr &amp;req, MiddlewareNextCallback &amp;&amp;nextCb, MiddlewareCallback &amp;&amp;mcb)=0</div></div>
<div class="ttc" id="aclassdrogon_1_1HttpResponse_html_ae7dbe82af88eae091b7684edb67d5f99"><div class="ttname"><a href="classdrogon_1_1HttpResponse.html#ae7dbe82af88eae091b7684edb67d5f99">drogon::HttpResponse::newNotFoundResponse</a></div><div class="ttdeci">static HttpResponsePtr newNotFoundResponse(const HttpRequestPtr &amp;req=HttpRequestPtr())</div><div class="ttdoc">Create a response which returns a 404 page.</div></div>
<div class="ttc" id="anamespacedrogon_html_a5200699555f98a809538342baa167aad"><div class="ttname"><a href="namespacedrogon.html#a5200699555f98a809538342baa167aad">drogon::HttpRequestPtr</a></div><div class="ttdeci">std::shared_ptr&lt; HttpRequest &gt; HttpRequestPtr</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:26</div></div>
<div class="ttc" id="anamespacedrogon_html_a6a361b482e0084d11cbebeed1677d577"><div class="ttname"><a href="namespacedrogon.html#a6a361b482e0084d11cbebeed1677d577">drogon::MiddlewareCallback</a></div><div class="ttdeci">std::function&lt; void(const HttpResponsePtr &amp;)&gt; MiddlewareCallback</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:35</div></div>
<div class="ttc" id="anamespacedrogon_html_aac356e8eb8bbc103efe2910214850e98"><div class="ttname"><a href="namespacedrogon.html#aac356e8eb8bbc103efe2910214850e98">drogon::MiddlewareNextCallback</a></div><div class="ttdeci">std::function&lt; void(std::function&lt; void(const HttpResponsePtr &amp;)&gt; &amp;&amp;)&gt; MiddlewareNextCallback</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:37</div></div>
<div class="ttc" id="anamespacedrogon_html_ab2a2d829bb017f43c2c9de72f4042baa"><div class="ttname"><a href="namespacedrogon.html#ab2a2d829bb017f43c2c9de72f4042baa">drogon::HttpResponsePtr</a></div><div class="ttdeci">std::shared_ptr&lt; HttpResponse &gt; HttpResponsePtr</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:24</div></div>
</div><!-- fragment --> 
</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li><a class="el" href="HttpMiddleware_8h_source.html">HttpMiddleware.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
